Welcome![Sign In][Sign Up]
Location:
Search - ti N

Search list

[Other用c编写的N*N的螺旋矩阵源代码

Description:

/*
实现效果:
1 2 6 7 15
3 5 8 14 16
4 9 13 17 22
10 12 18 21 23
11 19 20 24 25
*/
#include <stdio.h>
#define N 5 //阶数,即N*N的螺旋矩阵

void main()
{
    int i, j, num=1, a[N][N];
    for(i=0; i<=N/2; i++)
    {
        for(j=i; j<N-i; j++) a[i][j]=n++;
        for(j=i+1; j<N-i; j++) a[j][N-i-1]=n++;
        for(j=N-i-2; j>i; j--) a[N-i-1][j]=n++;
        for(j=N-i-1; j>i; j--) a[j][i]=n++;
    }
    for(i=0; i<N; i++)
    {
        for(j=0; j<N; j++)
            printf("%2d ",a[i][j]);
        printf("\n");
    }
}
    

 

不知道叫什么,先叫它“回宫图”吧
年初的时候在贴吧瞎逛,看到了一个程序挺有意思,会输出如下的形状:
01 24 23 22 21 20 19
02 25 40 39 38 37 18
03 26 41 48 47 36 17
04 27 42 49 46 35 16
05 28 43 44 45 34 15
06 29 30 31 32 33 14
07 08 09 10 11 12 13
仔细看这个形状,数字是按顺序往里回旋的,觉得很有创意,可是一看源代码头就大了,
每个编程人都知道看别人的代码是很困难的,尤其像这种不知道思路的,所以也就放下
没管了。
昨天上物理课实在是没心思听,就想起这个程序,想了一节课,果然不负有心人,给弄出来了,这个是增强版的,可以输入1-10中的任意个数,然后生成图形。
先看代码,没有注释,所以不好看的懂。
#include<stdio.h>
main()
{
       int n,m,i,j,t,k=1;
       int a[11][11];
       clrscr();
       do{
       printf("please input a number(1-10):");
       scanf("%d",&n);
       }while(n<1||n>10);
       t=n+1;
       for(m=1;m<=t/2;m++)
         {
           for(i=m;i<=t-m;i++)
             {a[i][m]=k;k++;}
           for(j=m+1;j<=t-m;j++)
             {a[i-1][j]=k;k++;}
           for(i=n-m;i>=m;i--)
             {a[i][j-1]=k;k++;}
           for(j=n-m;j>=m+1;j--)
             {a[i+1][j]=k;k++;}
         }
       for(i=1;i<=n;i++)
         {
           for(j=1;j<=n;j++)
             {
               if(a[i][j]<=9) printf("0%d ",a[i][j]);
               else printf("%d ",a[i][j]);       }
           printf("\n");
         }
       getch();
}
就是这样的。


可以更简洁些:

#include<stdio.h>
main()
{
       int n,m,i,j,t,k=1;
       int a[11][11];
       clrscr();
       do{
       printf("please input a number(1-10):");
       scanf("%d",&n);
       }while(n<1||n>10);
       t=n+1;
       for(m=1;m<=t/2;m++)
         {
           for(i=m;i<=t-m;i++)
             a[i][m]=k++;
           for(j=m+1;j<=t-m;j++)
             a[i-1][j]=k++;
           for(i=n-m;i>=m;i--)
             a[i][j-1]=k++;
           for(j=n-m;j>=m+1;j--)
             a[i+1][j]=k++;
         }
       for(i=1;i<=n;i++)
         {
           for(j=1;j<=n;j++)
             {
               if(a[i][j]<=9) printf("0%d ",a[i][j]);
               else printf("%d ",a[i][j]);       }
           printf("\n");
         }
       getch();
}

 


 #include <stdio.h>
#define N 8
main(){
 int i,j,n=1,a[N][N];
 for(i=0;i<=N/2;i++){
  for(j=i;j<N-i;j++)
   a[i][j]=n++;
  for(j=i+1;j<N-i;j++)
   a[j][N-i-1]=n++;
  for(j=N-i-2;j>i;j--)
   a[N-i-1][j]=n++;
  for(j=N-i-1;j>i;j--)
   a[j][i]=n++;
 }
 for(i=0;i<N;i++){
  printf("\n\n");
  for(j=0;j<N;j++)
   printf("%5d",a[i][j]);
 }
}
 

 


                                马踏棋盘问题


#include <stdio.h>
#define N 5
void main(){
 int x,y;
 void horse(int i,int j);
 printf("Please input start position:");
 scanf("%d%d",&x,&y);
 horse(x-1,y-1);
}
void horse(int i,int j){
 int a[N][N]={0},start=0,
  h[]={1,2,2,1,-1,-2,-2,-1},
  v[]={2,1,-1,-2,2,1,-1,-2},
  save[N*N]={0},posnum=0,ti,tj,count=0;
 int jump(int i,int j,int a[N][N]);
 void outplan(int a[N][N]);
 a[i][j]=posnum+1;
 while(posnum>=0){
  ti=i;tj=j;
  for(start=save[posnum];start<8;++start){
   ti+=h[start];tj+=v[start];
   if(jump(ti,tj,a))
    break;
   ti-=h[start];tj-=v[start];
  }
  if(start<8){
   save[posnum]=start;
   a[ti][tj]=++posnum+1;
   i=ti;j=tj;save[posnum]=0;
   if(posnum==N*N-1){
    //outplan(a);
    count++;
   }
  }
  else{
   a[i][j]=0;
   posnum--;
   i-=h[save[posnum>;j-=v[save[posnum>;
   save[posnum]++;
  }
 }
 printf("%5d",count);
}
int jump(int i,int j,int a[N][N]){
 if(i<N&&i>=0&&j<N&&j>=0&&a[i][j]==0)
  return 1;
 return 0;
}
void outplan(int a[N][N]){
 int i,j;
 for(i=0;i<N;i++){
  for(j=0;j<N;j++)
   printf("%3d",a[i][j]);
  printf("\n");
 }
 printf("\n");
 //getchar();
}
用回溯法得到所有的解,但效率较低,只能算出5行5列的

 


Platform: | Size: 4395 | Author: good@588 | Hits:

[GDI-Bitmapvb等值线图的绘制方法※编程实践※水论坛

Description: 等值线 在科学计算和现实生活中,常常会遇到y=f(t)这类函数关系,例如,正弦、余弦等等。函数y=f(t)往往是以离散的观测值形式f(ti)(i=1,....N)表现出来的。例如,令股民朋友如醉如痴的K线图,与千家万户性命攸关的河流水位曲线图等等。离散函数关系有不少数据处理课题,例如,数据拟合、插值和平滑等等。最令人兴奋的还是预测,如果股民朋友能够准确把握y=f(t)的走向,钞票就会源源不断涌入口袋。如果水文学家能够准确预测河流水位暴涨的过程,可以大量减少生命和财产损失。 所谓画曲线就是描绘y=f(t)的图象,在本书我们将通过图象绘制直观地了解观测值的变化和数据处理方法的效果-contours in scientific computing and real-life, we will often encounter y = f (t) such a function, such as sine, cosine and so on. Function y = f (t) tend to be discrete observation form f (t) (i = 1 ...... N) the performance. For example, investors simply friends of K map, and the millions of lives at stake curve of water levels in rivers and so on. Discrete function of a number of data-processing tasks, such as data fitting, interpolation and smoothing and so on. Most exciting is predicted that if shareholders friends to accurately grasp y = f (t) trend, money will continue to flood into pockets. If hydrologists can accurately predict river levels rose process, a significant reduction in loss of life and property. The so-called curve is painting depicting y = f (t) of the image, in this
Platform: | Size: 15069 | Author: PBC | Hits:

[Other resourceTI 54x fft

Description: DSP编程代码,FFT算法,经典!! FFT实验 一、 理论: 公式(1)FFT运算公式 FFT并不是一种新的变换,它是离散傅立叶变换(DFT)的一种快速算法。由于我们在计算DFT时一次复数乘法需用四次实数乘法和二次实数加法;一次复数加法则需二次实数加法。每运算一个X(k)需要4N次复数乘法及2N+2(N-1)=2(2N-1)次实数加法。所以整个DFT运算总共需要4N^2次实数乘法和N*2(2N-1)=2N(2N-1)次实数加法。如此一来,计算时乘法次数和加法次数都是和N^2成正比的,当N很大时,运算量是可观的,因而需要改进对DFT的算法减少运算速度。 根据傅立叶变换的对称性和周期性,我们可以将DFT运算中有些项合并。 我们先设序列长度为N=2^L,L为整数。将N=2^L的序列x(n)(n=0,1,……,N-1),按N的奇偶分成两组,也就是说我们将一个N点的DFT分解成两个N/2点的DFT,他们又从新组合成一个如下式所表达的N点DFT: 一般来说,输入被假定为连续、合成的。当输入为纯粹的实数的时候,我们就可以利用左右对称的特性更好的计算DFT。 我们称这样的RFFT优化算法是包装算法:首先2N点实数的连续输入称为“进包”。其次N点的FFT被连续被运行。最后作为结果产生的N点的合成输出是
Platform: | Size: 439370 | Author: 徐克 | Hits:

[Other resourceC2xxFFT算法函数包

Description: ti公司的c2x系列的fft的算法包 信号处理必备-ti n. fft series of signal processing algorithms required packet
Platform: | Size: 89709 | Author: bsy | Hits:

[Ftp ClientSEEDVPM642_net

Description: TI的DSP网络部分网络的接口测试的程序。通过闭环发送和接收。程序为TI编写,网络队列和堆栈的操作十分经典。-TI DSP network parts of the network interface test procedures. Through closed-loop send and receive. TI procedures for the preparation, network stack and queue operation classical.
Platform: | Size: 487424 | Author: 靳朝 | Hits:

[DSP programC2xxFFT算法函数包

Description: ti公司的c2x系列的fft的算法包 信号处理必备-ti n. fft series of signal processing algorithms required packet
Platform: | Size: 89088 | Author: bsy | Hits:

[mpeg mp3mpeg2dump.tar

Description: LibMPEG3 decodes several MPEG standards into uncompressed data suitable for editing and playback. libmpeg3 currently decodes: MPEG-2 video MPEG-1 video mp3 audio mp2 audio ac3 audio MPEG-2 transport streams MPEG-2 program streams MPEG-1 program streams IFO files The video output can be in many different color models and frame sizes. The audio output can be in twos compliment or floating point. Frame accurate seeking, normally impossible in transport streams, is possible in libmpeg3 through the use of a table of contents. MPEG-2 video in YUV-422 colorspace is decodable. Digital TV broadcasts and DVD s can be edited using libmpeg3. Libmpeg3 takes what is normally a last mile distribution format and makes it editable. Because of these and other features libmpeg3 is not intended for consumer applications but serves users who are interested in high quality editing and footage acquisition. -several LibMPEG3 decodes MPEG standards i nto uncompressed data suitable for editing and playback. libmpeg3 currently decodes : MPEG-2 video in MPEG-1 video mp3 audio mp2 audio ac 3 audio MPEG-2 transport streams MPEG-2 progr m streams MPEG-1 program streams IFO files The v ideo output can be in many different color model 's and frame sizes. The audio output can be in twos compliment or floating point. Frame's accurate eeking. normally impossible in transport streams. in libmpeg3 is possible through the use of a tabl e of contents. MPEG-2 video in YUV-422 colorspa ce is decodable. Digital TV broadcasts and DVD's can be edited using libmpeg3. Libmpeg3 takes wh at is normally a last mile a distribution format nd makes it editable. Because of these and other libmpeg3 features is n
Platform: | Size: 712704 | Author: robo | Hits:

[DSP programNDKforTIDM642DSP

Description: 开发TIC6000DSP经典重要资料,NDK(Network Development Kit) for TI C6000 DSP,本人费尽心血才搞到的,是开发DSP网络通讯的基础.-development TIC6000DSP classical important information NDK (Network Development Kit) for TI C6000 DSP, I only made a painstaking, and the development of DSP-based communications network.
Platform: | Size: 539648 | Author: John NI | Hits:

[Data structsex

Description: 最佳调度问题,假设有n个任务由k个可并行工作的机器完成。完成任务i需要的时间为ti。试设计一个算法找出完成这n个任务的最佳调度,使得完成全部任务的时间最早。 -Optimal scheduling problem, assuming that n has a mission by the k-parallel machine to complete the work. I need to complete the mission time for ti. Try to design an algorithm to find n complete this task the best scheduling, making the time to complete a full first mission.
Platform: | Size: 1024 | Author: 朱亚华 | Hits:

[DSP programti.ndk.platforms.dsk6455_1_94_0_0

Description: TI公司的NSP,ndk开发必备 dsp网络实现-TI
Platform: | Size: 2302976 | Author: liuyi | Hits:

[Otherriddle

Description: 【题目描述】 小伟报名参加中央电视台的智力大冲浪节目。本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元。先不要太高兴!因为这些钱还不一定都是你的。接下来主持人宣布了比赛规则: 首先,比赛时间分为n个时段(n≤500),它又给出了很多小游戏,每个小游戏都必须在规定期限ti前完成(1≤ti≤n)。如果一个游戏没能在规定期限前完成,则要从奖励费m元中扣去一部分钱wi,wi为自然数,不同的游戏扣去的钱是不一样的。 -【Description】 Xiaowei subject enrolled in the intellectual CCTV shows great surfing. The Challenge attracted a large number of participants, in order to host the U.S. in recognition of courage, to reward participants m each element. Should not be too pleased! Not necessarily because they are paying the money for you. Then the host announced the game rules: First of all, the game is divided into n time periods (n ≤ 500), it gives a lot of small games, each game must be completed before the ti period (1 ≤ ti ≤ n). If a game is not completed before the set time period, the element m from the incentive fee deduct the money as part of wi, wi for the natural number, different deduction of the Games is not the same as money.
Platform: | Size: 13312 | Author: faruh | Hits:

[Software EngineeringDesignandDSPrealizationofan0FDMreceiver

Description: 设计了一个OFDM接收机,并采用1fI公司的TMS320C6416芯片进行实现。在假设理想 同步的前提下,该系统进行了FFT变化、使用了Ls(最小二乘法)进行信道估计,并且采用了 QPSK算法进行解调。最后将接收机输出数据与发端数据进行比较,在不同信噪比情况下计算其 误码率,得出了比较理想的结果。-An OFDM receiver is designed in山is paper and realized on the platform of the 1MS32OC6416 chip of the TI company.Under the assumption of ideal synchronization.n叩transformation is realized in the system wit}l LS method implemented in the channel estimation module and QPSK used in the demodulation module. Finally,BER is calculated in different cases of SNR and the result is achieved as expected.
Platform: | Size: 243712 | Author: 王熹 | Hits:

[Delphi VCLF2KDUMP

Description: 东莞域天F2K加密锁HID监听,可在C盘产生记录文件-东莞域天F2K加密锁HID监听,可在C盘产生记录文件 Translate from: Chinese Allow phonetic typingType text or a website address or translate a document. Cancel Dōngguǎn yù tiān F2K jiāmì suǒ HID jiāntīng, kě zài C pán chǎnshēng jìlù wénjiànEnglishSpanishArabicAlpha The Dongguan domain F2K encryption lock HID monitor can generate a log file on the C drive
Platform: | Size: 13312 | Author: YLZ | Hits:

[VHDL-FPGA-Verilog2011-04-27-Stepper-motor-control-TI-DRV8332DKD.zi

Description: Stepper-Motor Control for TI-DRV8332DKD. Operation with steps of N kHz, while n > 1. Functionality: Forward, backward, hold, stand-by
Platform: | Size: 1602560 | Author: Abel Tazzman | Hits:

[e-languageCPAtuiangguang

Description: 非cpa日赚50以上不作弊 这是CPA推广注册软件源码到时候用E语言把地址改成你的就可以用了如果肯推的话一天很多。-非cpa日赚50以上不作弊 这是CPA推广注册软件源码到时候用E语言把地址改成你的就可以用了如果肯推的话一天很多 请键入文字或网站地址,或者上传文档。 取消 Fēi cpa rì zhuàn 50 yǐshàng bù zuòbì zhè shì CPA tuīguǎng zhùcè ruǎnjiàn yuánmǎ dào shíhou yòng E yǔyán bǎ dìzhǐ gǎi chéng nǐ de jiù kěyǐ yòng liǎo rúguǒ kěn tuī dehuà yītiān hěnduō “”的用法示例:由 Google 自动翻译英语中文(简体)日语Non-cpa earn 50 not cheating CPA promotion registration software source code to when E language changed to the address you can use if you are willing to push day many
Platform: | Size: 14596096 | Author: lijin | Hits:

[Software Engineeringdian-ti--fanzhenxintongsejie

Description: . E8、E9: 可到达1~~39层。 2.2 每部电梯的最大乘员量均为K人(K值可以根据仿真情况在10—20 人之间确定)。 2.3 仿真开始时,各电梯随机处于起符合运行规则的任意一层,为空梯。 2.4 仿真开始后,有N人(1000>N)在M分钟(10>M)内随机地到达该国际贸易中心的一层, 开始乘梯活动。 2.5 每个人初次所要到的楼梯层是随机的,令其在合适的电梯处等待电梯的到来。 2.6 每个人乘坐的合适电梯到达指定楼层后,随机地停留10—120秒后,在随机地去往另一 楼层,依次类推,当每个人乘坐过L次(L值可以根据仿真情况在3—10次之间确定)电梯后,第L+1次为下至底层并结束乘梯行为。到所有人结束乘梯行为时,本次仿真结束。 2.7 电梯运行速度为S秒/层(S值可以根据仿真情况在1—5之间确定),每个人-. E8, E9: 1 to 39 layer can be reached. The maximum amount of the occupant of 2.2 per lifts are K (K value can be determined between 10-20) According to the simulation case. 2.3 simulation, elevator random in any operating rules from the floor, empty ladder. 2.4 After the start of the simulation, N (1000 N) M minute (10 M) to reach the floor of the International Trade Centre random start by ladder. 2.5 per person for the first time to go to the stairs layer is random, so that it waiting for the arrival of the elevator in the elevator. The 2.6 each person take the appropriate elevator to reach the designated floor, randomly stop after 10-120 seconds, randomly go to another floor, and so on, when everyone rode L (L value according to the simulation case 3- 10 OK) Elevator, L+1 down to the bottom and the end of the boarding behavior. To the end of all acts of the boarding, the end of the simulation. Elevator speed 2.7 sec/S layer (S-value can be determined between 1-5) According to the si
Platform: | Size: 327680 | Author: 万利 | Hits:

[OthergameScheme

Description: 小伟报名参加中央电视台的智力大冲浪节目,本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元。先不要太高兴!因为这些钱还不一定都是你的!接下来主持人宣布了比赛规则: 首先,比赛时间分为n个时段(n≤500),它又给出了很多小游戏,每个小游戏都必须在规定期限ti前完成(1≤ti≤n)。如果一个游戏没能在规定期限前完成,则要从奖励费m元中扣去一部分钱wi,wi为自然数,不同的游戏扣去的钱是不一样的。当然,每个游戏本身都很简单,保证每个参赛者都能在一个时段内完成,而且都必须从整时段开始。主持人只是想考考每个参赛者如何安排组织自己做游戏的顺序。作为参赛者,小伟很想赢得冠军,当然更想赢取最多的钱!注意:比赛绝对不会让参赛者赔钱! -Xiaowei enroll CCTV intellectual big surf program, The Challenge has attracted many participants, we commend the courage to host first award each participant m, respectively. Let us not be too happy! Because these are not necessarily paying the money you! Then the host announced the rules of the game: First, the game is divided into n time periods (n ≤ 500), it also gives a lot of games, each game must be completed before the specified period ti (1 ≤ ti ≤ n). If a game could not be completed before the specified period, the deduction from the fee m-ary part of the money in reward wi, wi is a natural number, different game deduct money is not the same. Of course, every game itself is very simple, to ensure that each participant can be completed within a period of time, but must start from the entire period. Moderator just want to quiz each participant how to make their own arrangements for the organization of the game in order. As a participant, Xiaowei wanted to win, of course, want t
Platform: | Size: 504832 | Author: marry | Hits:

[matlabZ-N法整定PID控制器参数

Description: 用MATLAB程序软件完成临界比例带法对PID控制器的参数整定,并求出PID控制器的三个参数Kp,Ti,Td。最后绘制出参数整定前后的单位阶跃响应图进行比较。(The parameters of PID controller are adjusted by MATLAB software and the three parameters Kp, Ti and Td of PID controller are obtained. Finally, the unit step response diagram before and after parameter tuning is drawn.)
Platform: | Size: 7168 | Author: hhhhyy | Hits:

[matlab用Z-N法实现P,PI,PID控制的参数整定

Description: 用MATLAB程序软件完成Z-N法对控制器的参数整定,实现P,PI,PID控制器的分别参数整定,并求出控制器的控制参数Kp,Ti,Td。最后绘制出不同控制器控制下的及参数整定前后的单位阶跃响应图进行比较。(MATLAB program software is used to complete the parameter tuning of the controller by Z-N method. The parameters of P, PI, PID controller are adjusted, and the control parameters of the controller Kp, Ti, Td are obtained. Finally, the unit step response diagram before and after parameter tuning is plotted under different controller control.)
Platform: | Size: 7168 | Author: hhhhyy | Hits:

[DocumentsTừ điển viet nhật

Description: Từ điển tiếng viet tiếng nhật
Platform: | Size: 18074464 | Author: tonynguyen | Hits:
« 12 3 4 5 »

CodeBus www.codebus.net